package com.gst.cloudygovernance.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.gst.cloudygovernance.fragment.DayFragment;
import com.gst.cloudygovernance.fragment.MonthFragment;
import com.gst.cloudygovernance.fragment.WeekFragment;
import com.gst.cloudygovernance.fragment.YearFragment;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by CHENG on 2017/12/17.
 */

public class AlarmPagerAdapter extends FragmentPagerAdapter {
    private String[] titles = new String[]{"本日","本周","本月","本年"};
    private List<Fragment> fragmentList = new ArrayList<>();
    private DayFragment dayFragment;
    private WeekFragment weekFragment;
    private MonthFragment monthFragment;
    private YearFragment yearFragment;

    public AlarmPagerAdapter(FragmentManager ft) {
        super(ft);
        initFragments();
    }

    private void initFragments() {
        if (dayFragment==null&&weekFragment==null&&monthFragment==null&&yearFragment==null) {
            fragmentList.add(new DayFragment());
            fragmentList.add(new WeekFragment());
            fragmentList.add(new MonthFragment());
            fragmentList.add(new YearFragment());
        }

    }

    @Override
    public int getCount() {
        return fragmentList==null?0:fragmentList.size();
    }

    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);
    }


    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }

}
